
<template>
  <el-tabs v-model="activeName2" type="card" @tab-click="handleClick">
    <el-tab-pane label="用户管理" name="first">

        <div class="small">
          姓名：<el-input type="text" placeholder="根据姓名查询" size="mini" autosize=""/>
        </div>
        <div>
          身份证：<el-input placeholder="根据身份证查询"/>
        </div>

    </el-tab-pane>
    <el-tab-pane label="配置管理" name="second">

       <el-transfer
    filterable
    filter-placeholder="请输入套餐名称"
    v-model="value2"
    :titles="['全部套餐','已选择套餐']"
    @change="handleChange"
    :data="transferData">
  </el-transfer>

    </el-tab-pane>
  </el-tabs>
</template>
<script>
import {setmeal} from '@/api/setmeal.js'
  export default {
    data() {
       /* const generateData2 = _ => {
        const data = [];
        const cities = ['上海', '北京', '广州', '深圳', '南京', '西安', '成都'];
        const pinyin = ['shanghai', 'beijing', 'guangzhou', 'shenzhen', 'nanjing', 'xian', 'chengdu'];
        cities.forEach((city, index) => {
          data.push({
            label: city,
            key: index,
            pinyin: pinyin[index],

          });
        });
        return data;
      }; */
      return {

       activeName2: 'first',

        transferData:[],
        value2: [],
       /*  filterMethod(query, item) {
          return item.pinyin.indexOf(query) > -1;
        } */
      };
    },
    methods: {

      handleChange(value, direction){
           console.log(value, direction);

           console.log(value[0])
      },

      handleClick(tab, event) {

      },

      async pageInit(){
        try{
          let [res] =await Promise.all([
            setmeal()
          ])

          console.log(res.data)



				const allData = res.data

				const data = [];



				for(let i = 0; i < allData.length; i++) {
					data.push({
						key: allData[i].id,
						label: allData[i].name,
					});
				}


				this.transferData = data;


        }catch(error){
            console.log(error);
        }

     },

    },
    created(){
      this.pageInit();

    }
  };
</script>
